package com.ckh.springboot.controller;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ckh.springboot.common.Constants;
import com.ckh.springboot.common.Result;
import com.ckh.springboot.controller.dto.UserPasswordDTO;
import com.ckh.springboot.entity.StudentResult;
import com.ckh.springboot.entity.User;
import com.ckh.springboot.mapper.UserMapper;
import com.ckh.springboot.service.IStudentResultService;
import com.ckh.springboot.service.IUserService;
import com.ckh.springboot.vo.UserVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ckh
 * @since 2022-04-04
 */
@RestController
@RequestMapping("/api/studentResult")
public class StudentResultController {


    @Resource
    private IStudentResultService studentResultService;

    /**
     * Description:a
     * 查询成绩
     * @author: luoCan
     */
    @GetMapping("/getResult")
    public Result getResult(@RequestParam Integer userId) {
        List<StudentResult> list = studentResultService.list(Wrappers.<StudentResult>lambdaQuery().eq(StudentResult::getUserId, userId));
        return Result.success(list);
    }


    /**
     * Description:a
     * 发布成绩
     * @author: luoCan
     */
    @PostMapping("/resultInsert")
    public Result resultInsert(@RequestBody StudentResult studentResult) {
        return Result.success(studentResultService.save(studentResult));
    }

}

